<template>
    <div>
        <mu-appbar style="width: 100%;" color="primary" fixed>
        <mu-button icon slot="left" @click="goback">
            <mu-icon value="reply"></mu-icon>
        </mu-button>
        签到
        <mu-button icon slot="right" >
            <mu-icon value="more_horiz"></mu-icon>
        </mu-button>
        </mu-appbar>
        <br><br>
        <img src="../../assets/images/signin.png" alt="">
<br>
        <mu-button type="text" color="success" @click="signin()" >签到</mu-button>
    </div>
</template>

<script>
import moment from "moment";
import axios from 'axios'
export default {
  data() {
        axios
      .get("/api/activity/getactdetail", {
        params: {
          id: this.$route.query.id
        }
      })
      .then(res => {
        this.act = res.data.data;
        console.log(this.act);
      })
      .catch(err => {
        console.log(err);
      });
    return {
        act:'',
    };
  },
  methods: {
    goback() {
      this.$router.go(-1); //返回上一层
    },
    signin() {
      if (Date.now() < this.starttime || Date.now() > this.endtime) {
        Toast.error("不在活动时间内");
      } else {
        let signTime = moment(Date.now()).format("YYYY-MM-DD HH:mm");
        console.log(this.act._id, this.act.signlist[0]._id);
        axios
          .post("/api/activity/signin", {
            actid: this.act._id,
            actid2: this.act.signlist[0]._id,
            time: signTime
          })
          .then(result => {
            if (result.data == "签到成功") {
              console.log("签到成功");
            }
          });
      }
    }
  },mounted(){
     
  }
  
};
</script>

<style>
</style>
